from mega.baseop.abstracts import AbstractMerger
from extra_service.setflow import EntrySet
from mega.baseop.operio import OperatorOutput


class EntrySetMerger2(AbstractMerger):

    def __init__(self, config):
        super().__init__(config)
    
    def doOpen(self):
        return super().doOpen()
    
    def doClose(self):
        return super().doClose()
    
    def doProcess(self, chan01:EntrySet, chan02:EntrySet):
        if not isinstance(chan01,EntrySet):
            raise Exception("type error, chan01 is not EntrySet")
        if not isinstance(chan02,EntrySet):
            raise Exception("type error, chan02 is not EntrySet")
        overall = EntrySet()
        overall.Merge(chan01)
        overall.Merge(chan02)
        return OperatorOutput(out=overall)


class EntrySetMerger3(AbstractMerger):

    def __init__(self, config):
        super().__init__(config)
    
    def doOpen(self):
        return super().doOpen()
    
    def doClose(self):
        return super().doClose()
    
    def doProcess(self, chan01:EntrySet, chan02:EntrySet, chan03:EntrySet):
        if not isinstance(chan01,EntrySet):
            raise Exception("type error, chan01 is not EntrySet")
        if not isinstance(chan02,EntrySet):
            raise Exception("type error, chan02 is not EntrySet")
        if not isinstance(chan03,EntrySet):
            raise Exception("type error, chan03 is not EntrySet")
        overall = EntrySet()
        overall.Merge(chan01)
        overall.Merge(chan02)
        overall.Merge(chan03)
        return OperatorOutput(out=overall)


